#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> height(n);
	for(int i=0;i<n;i++){
		cin>>height[i];
	}

	int l = 0;
	int r = height.size()-1;
	int ans = 0;
	
    while (l < r) {
        int area = min(height[l], height[r]) * (r - l);
        ans = max(ans, area);
        if (height[l] <= height[r]) {
            ++l;
        }
        else {
            --r;
        }
    }
    cout<< ans;
	
	return 0;
} 
